<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	function getComment(){ //모든댓글을 가져오는 함수 정의
		 $.ajax({
		type:"post",
		url:"getAllComment.do",
		data:"no=${requestScope.bvo.no}", //게시물의 번호를 전송
		dataType:"json",
		success:function(data){
			//alert(data);
			var str="";
			//var form = "<c:if test='${sessionScope.loginMember!=value.memberVO.id }'>수정 삭제</c:if>";
			$.each(data,function(index,value){
				var form = "수정 ";
				form+="<a href='deleteComment.do?no="+value.no+"'>삭제</a> ";
				str+=value.memberVO.id+" "+value.date+" "+form+"<br>"+value.content+"<br>";
			});
			$("#commentView").html(str); //댓글 영역에 표시한다
		}//callback
	});//ajax 
	}//getComment
	$(function(){
		getComment(); //페이지 레디시 모든 댓글 호출
		$("#updateBoard").click(function(){ //게시글 수정 
			if(confirm("게시글을 수정하시겠습니까?")){
				return false;
			}//if
		});//updateBoard click
		$("#deleteBoard").click(function(){ //게시글 삭제
			if(confirm("게시글을 삭제하시겠습니까?")){
				return false;
			}//if
		});//updateBoard click
		$("#commentBtn").click(function(){ //댓글등록 버튼
			 $.ajax({
					type:"post",
					url:"writeComment.do",
					data:$("#commentForm").serialize(), //댓글정보를 전송
					dataType:"json",
					success:function(flag){
						if(!flag){
							alert("댓글등록 실패");
						}
							$("textarea[name=content]").val("");
							getComment();
					}//callback
			 });//ajax
		});//commentBtn click
		
		
	});//ready
</script>

${requestScope.bvo.no } / ${requestScope.bvo.title} / ${requestScope.bvo.memberVO.id} / ${requestScope.bvo.hit}
<br>
${requestScope.bvo.content}
<hr>
<div id="commentView">댓글영역</div>
<form id="commentForm" method="post">
	<textarea rows="2" cols="20" name="content"></textarea>
	<input type="hidden" name="memberVO.id" value="java">
	<input type="hidden" name="boardNo" value="${requestScope.bvo.no}">
	<input type="button" value="댓글등록" id="commentBtn">
</form>
<input type="button" value="목록">
<c:if test="${sessionScope.loginMember!=null }">
<input type="button" value="수정" id="updateBoard">
<input type="button" value="삭제" id="deleteBoard">
</c:if>
<input type="button" value="답글">













